<script type="text/javascript" language="javascript">
function ListingLevel(val)
	{
		if(val==1)
		{
			document.getElementById('premiumid').style.display='none';
		}
		else
		{
			document.getElementById('premiumid').style.display='inline';
		}
	}
	
var wordLimit = 50;
	var holdText;
	var disabledBox = false;
	function countEm()
	{
	 var text1 = document.adsaddfrm.businessdesc.value;
	 var text2 = text1.replace(/\s+/g, ' ');
	 var text3 = text2.split(' ');
	 var numberOfWords = text3.length;
	 
	 if(numberOfWords == wordLimit)
	 {
	  holdText = text1;
	 }//end if

	
	 //write number of words left to another field
	 if((wordLimit - numberOfWords) <= 0)
	 {
		 document.adsaddfrm.wordcount.value = 0;
	 }
	 else
	 {
	 	document.adsaddfrm.wordcount.value = wordLimit - numberOfWords;
	 }
	
	 if(numberOfWords > wordLimit)
	  alert('You have reached the number of words limit');
	}
	
	function doCount(textParam)
	{
	 //replace all instances of one-or-more spaces with a single space
	 var text2 = textParam.replace(/\s+/g, ' ');
	
	 //trim leading and tailing spaces
	 while(text2.substring(0, 1) == ' ')
	  text2 = text2.substring(1);
	 while(text2.substring(text2.length-2, text2.length-1) == ' ')
	  text2 = text2.substring(0,text2.length-1);
	
	 var text3 = text2.split(' ');
	
	 return text3.length;
	}//end function
	
	function maybeReset()
	{
	 if(disabledBox)
	 {
	  var currText = document.adsaddfrm.ebusinessdesc.value;
	  var newLength = doCount(currText);
	
	  //prevent user from adding words, but not taking them away
	  if(newLength > wordLimit)
	  {
	   document.adsaddfrm.businessdesc.value = holdText;
	  }//end if
	 }//end if
	}//end function

</script>
<form name="adsaddfrm" method="post" action="index.php?tc=ads_addcode" enctype="multipart/form-data">
<?php
if($_REQUEST['_s'] == 1)
{?>
<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Submitted successfully</div></td>
    </tr>    
    </table>
<?php } ?>
<?php
if($_REQUEST['_e'] == 1)
{?>
<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/error.png" align="absmiddle" />&nbsp;Invalid file format.</div></td>
    </tr>    
    </table>
<?php } ?>
<?php
if($_REQUEST['_e'] == 2)
{?>
<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/error.png" align="absmiddle" />&nbsp;Transcation failed. Please try again.</div></td>
    </tr>    
    </table>
<?php } ?>
<table width="99%" align="center" border="0"  class="list" cellpadding="5" cellspacing="0">
<thead>
<tr>
	<td colspan="2" align="left">
        <div style="float:left">Add Business</div>
        <div style="float:right"><a href="index.php?tc=ads">Back</a></div>
    </td>
</tr>
</thead>
<tr>
	<td align="right" width="150">Item to Advertise</td>
    <td align="left"><input class="text" name="item" type="text"/></td>
</tr>
<tr>
	<td align="right" width="150">Short Description</td>
    <td align="left"><textarea name="desc" cols="30" rows="4" wrap="soft"></textarea></td>
</tr>
<tr>
	<td align="right" width="150">Category</td>
    <td align="left"><input type="checkbox" name="realestate" value="realestate"  />&nbsp; Real Estate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	<input type="checkbox" name="business" value="business"  />&nbsp; Business<br />
            <input type="checkbox" name="jobs" value="jobs"  />&nbsp; Jobs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        	<input type="checkbox" name="motorvehicles" value="motorvehicles"  />&nbsp; Motor Vehicles<br />
            <input type="checkbox" name="announcements" value="announcements"  />&nbsp; Announcements&nbsp;&nbsp;&nbsp;
        	<input type="checkbox" name="other" value="other"  />&nbsp; Other Classifieds</td>
</tr>
<tr>
	<td align="right" width="150">Listing Level</td>
    <td align="left">
        	<input type="radio" name="listinglevel" value="1" checked="checked" onclick="ListingLevel(this.value)"  />&nbsp;STANDARD (2 categories)<br />
            <input type="radio" name="listinglevel" value="2" onclick="ListingLevel(this.value)"  />&nbsp;PREMIUM (4 categories)
   	</td>
</tr>
<thead>
<tr>
	<td colspan="2" align="left">
        <div style="float:left">Business Template Details</div>
    </td>
</tr>
</thead>
<tr>
    	<td colspan="2" align="center">
            	<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
                <tr>
                	<td align="right" width="150">Image 1</td>
                    <td align="left"><input type="file" name="tempimage1" /></td>
                </tr>
                <tr>
                	<td align="right" width="150">Image 2</td>
                    <td align="left"><input type="file" name="tempimage2"  /></td>
                </tr>
                </table>
            <div id="premiumid" style="display:none">
            	<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0">
                <tr>
                	<td align="right" width="150">Image 3</td>
                    <td align="left"><input type="file" name="tempimage3" /></td>
                </tr>
                <tr>
                	<td align="right" width="150">Image 4</td>
                    <td align="left"><input type="file" name="tempimage4"  /></td>
                </tr>
                <tr>
                	<td align="right" width="150">Image 5</td>
                    <td align="left"><input type="file" name="tempimage5"  /></td>
                </tr>
                <tr>
                	<td align="right" width="150">Image 6</td>
                    <td align="left"><input type="file" name="tempimage6"  /></td>
                </tr>    
                </table>
            </div>
        </td>
	</tr> 
<thead>
<tr>
	<td colspan="2" align="left">
        <div style="float:left">Business Contact Details</div>
    </td>
</tr>
</thead>
<tr>
	<td align="right" width="150">Contact Email</td>
    <td align="left">
	<input type="text" name="contactemail" class="text"  />
	</td>
</tr>
<tr>
	<td align="right" width="150">Show Contact Email</td>
    <td align="left">
	<input type="radio" value="1" name="showcontactemail" />&nbsp;Yes&nbsp;&nbsp;
    <input type="radio" value="0" name="showcontactemail" checked />No
	</td>
</tr>
<tr>
	<td align="right" width="150">Address 1</td>
    <td align="left">
	<input type="text" name="address1" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">Address 2</td>
    <td align="left">
	<input type="text" name="address2" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">City</td>
    <td align="left">
	<input type="text" name="city" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">State</td>
    <td align="left">
	<input type="text" name="state" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">Postcode</td>
    <td align="left">
	<input type="text" name="postcode" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">Phone</td>
    <td align="left">
	<input type="text" name="phone" class="text" />
	</td>
</tr>
<tr>
	<td align="right" width="150">Fax</td>
    <td align="left">
	<input type="text" name="fax" class="text" />
	</td>
</tr>
<thead>
<tr>
	<td colspan="2" align="left">
        <div style="float:left">Business Long Description</div>
    </td>
</tr>
</thead>
<tr>
	<td colspan="2" align="left">
        	<textarea name="businessdesc" cols="100" rows="5" wrap="soft" onkeydown='countEm();' onkeyup='maybeReset();' ></textarea><br />
            <input type="text" name="wordcount" value="50" style="width:30px;" readonly="readonly"  />
    </td>
</tr>
<tr>
    	<td align="left" colspan="2">
        	<input type="submit" value="Save and Submit for Approval" name="save_approval" />&nbsp;<input type="reset" value="Clear" />
        </td>
  	</tr> 
</table>
</form>